home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
APPEXPRT.PAK
/
TLISTBOX.OWL
< prev
next >
Wrap
Text File
|
1997-05-06
|
6KB
|
194 lines
<<[H]TListBox [[TListBox]]
##{hheader.snp}
#include <owl/listbox.h>
##<<TApplication QUERY_FILENAME_CPP [[Filename]]
#include "[[Filename]].rh" // Definition of all resources.
//{{TListBox = [[TListBox]]}}
class [[TListBox]] : public TListBox {
public:
[[TListBox]](TWindow* parent, int id, int x, int y, int w, int h, TModule* module = 0);
virtual ~[[TListBox]]();
##--BEGIN-- @OPT_APPL_PRINTING
//{{[[TListBox]]VIRTUAL_BEGIN}}
public:
virtual void Paint(TDC& dc, bool erase, TRect& rect);
##:DBVirtual(\\"[[TListBox]]", "Paint")
//{{[[TListBox]]VIRTUAL_END}}
//{{[[TListBox]]RSP_TBL_BEGIN}}
protected:
void EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo);
//{{[[TListBox]]RSP_TBL_END}}
DECLARE_RESPONSE_TABLE([[TListBox]]);
##--END-- @OPT_APPL_PRINTING
}; //{{[[TListBox]]}}
##{hfooter.snp}
>>[H]TListBox [[TListBox]]
<<[CPP]TListBox [[TListBox]]
##{cheader.snp}
#include <owl/pch.h>
##<<TApplication QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
##--BEGIN-- !@OPT_APPL_DOCVIEW
## --BEGIN-- @QUERY_APPL_MODEL == VALUE_MDI
##: <<TMDIChild QUERY_WIND_CLIENT [[Client]]
##: <<*Client QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
## --END-- @QUERY_APPL_MODEL == VALUE_MDI
## --BEGIN-- @QUERY_APPL_MODEL == VALUE_SDI
## --END-- @QUERY_APPL_MODEL == VALUE_SDI
##--END-- !@OPT_APPL_DOCVIEW
##QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
#include <stdio.h>
//{{[[TListBox]] Implementation}}
##--BEGIN-- @OPT_APPL_PRINTING
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 4
//
// Build a response table for all messages/commands handled
// by [[TListBox]] derived from TListBox.
//
DEFINE_RESPONSE_TABLE1([[TListBox]], TListBox)
//{{[[TListBox]]RSP_TBL_BEGIN}}
##:DBResponse(\\"[[TListBox]]", "", "", "WM_GETMINMAXINFO", "")
EV_WM_GETMINMAXINFO,
//{{[[TListBox]]RSP_TBL_END}}
END_RESPONSE_TABLE;
##--END-- @OPT_APPL_PRINTING
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TListBox]]
// ~~~~~~~~~~
// Construction/Destruction handling.
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
[[TListBox]]::[[TListBox]](TWindow* parent, int id, int x, int y, int w, int h, TModule* module)
:
TListBox(parent, id, x, y, w, h, module)
{
Attr.Style &= ~LBS_SORT; // Don't sort the list its a file.
Attr.Style |= LBS_NOINTEGRALHEIGHT; // Don't let it adjust within the frame
##QUERY_WIND_STYLE [[StyleAttributes]]
##StyleAttributes != "" 3
// Override the default window style for TListBox.
[[StyleAttributes]]
##{wndbkgd.snp}
// INSERT>> Your constructor code here.
}
[[TListBox]]::~[[TListBox]]()
{
Destroy();
// INSERT>> Your destructor code here.
}
##--BEGIN-- @OPT_APPL_PRINTING == TRUE
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
//
// Paint routine for Window, Printer, and PrintPreview for a TListBox client.
//
void [[TListBox]]::Paint(TDC& dc, bool, TRect& rect)
{
##<<TApplication QUERY_CLASS_NAME [[TApplication]]
[[TApplication]]* theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
if (theApp) {
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Only paint if we're printing and we have something to paint, otherwise do nothing.
//
if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
// Use pageSize to get the size of the window to render into. For a Window it's the client area,
// for a printer it's the printer DC dimensions and for print preview it's the layout window.
//
TSize pageSize(rect.right - rect.left, rect.bottom - rect.top);
HFONT hFont = (HFONT)GetWindowFont();
TFont font("Arial", -12);
if (!hFont)
dc.SelectObject(font);
else
dc.SelectObject(TFont(hFont));
TEXTMETRIC tm;
int fHeight = dc.GetTextMetrics(tm) ? tm.tmHeight + tm.tmExternalLeading : 10;
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// How many lines of this font can we fit on a page.
//
int linesPerPage = MulDiv(pageSize.cy, 1, fHeight);
if (linesPerPage) {
TPrintDialog::TData& printerData = theApp->Printer->GetSetup();
int maxPg = (GetCount() / linesPerPage) + 1.0;
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Compute the number of pages to print.
//
printerData.MinPage = 1;
printerData.MaxPage = maxPg;
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Do the text stuff:
//
int fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage;
int toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage;
int currentPage = fromPage;
TAPointer<char> buffer = new char[255];
while (currentPage <= toPage) {
int startLine = (currentPage - 1) * linesPerPage;
int lineIdx = 0;
while (lineIdx < linesPerPage) {
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// If the string is no longer valid then there's nothing more to display.
//
if (GetString(buffer, startLine + lineIdx) < 0)
break;
dc.TabbedTextOut(TPoint(0, lineIdx * fHeight), buffer, strlen(buffer), 0, 0, 0);
lineIdx++;
}
currentPage++;
}
}
}
}
}
void [[TListBox]]::EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo)
{
##<<TApplication QUERY_CLASS_NAME [[TApplication]]
[[TApplication]]* theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
if (theApp) {
if (theApp->Printing) {
minmaxinfo.ptMaxSize = TPoint(32000, 32000);
minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000);
return;
}
}
TListBox::EvGetMinMaxInfo(minmaxinfo);
}
##--END-- @OPT_APPL_PRINTING == TRUE
>>[CPP]TListBox [[TListBox]]